home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************/
- /* */
- /* StripMail */
- /* Copyright ©1997 by Dick Whiting */
- /* */
- /*----------------------------------------------------------------------------*/
- /* This strip attachment program strips: */
- /* */
- /* The Mime warning message at the beginning of the mail */
- /* Mime attachments and replaces them with a message including name */
- /* UUencoded files that are included as plain text */
- /* */
- /* It also fixes a couple minor things in badly formed mail: */
- /* Adds a null line after Header if missing */
- /* Adds boundary end if missing (prevent 0 byte attachment msg) */
- /* */
- /* NOTE: This one, like my other ones, retains the date/timestamp of the */
- /* original mail and its filenote. */
- /* */
- /* NOTE: Changes won't be visible in Yam until you do an UPDATE INDEX. */
- /* */
- /* NOTE: As long as you don't change the stripmsg value, you can run this */
- /* multiple times against the same mail and NOT lose the name of the */
- /* attachment that was stripped. */
- /* */
- /*----------------------------------------------------------------------------*/
- /* If you use YamTools you can use this one as a TYPE=ONCE to apply to mail */
- /* selected one at a time from YAM, or TYPE=MAIL to do all mail selected */
- /* from a YamTools list. Remember that you CAN define two buttons using */
- /* same script but with different TYPES. */
- /* */
- /* If you don't use YamTools--why not;) */
- /* */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
- /* that it will do anything productive for anyone else, etc. etc. ;-) */
- /* */
- /*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
- /*would love a postcard from where EVER you live. */
- /* */
- /*Instant GEOGRAPHY lesson;) */
- /* */
- /* */
- /*POSTCARDS: Dick Whiting */
- /* 28590 S. Beavercreek Rd. */
- /* Mulino, Oregon 97042 */
- /* USA */
- /* */
- /*----------------------------------------------------------------------------*/
- /* */
- /* Address Bug Reports or Comments to: */
- /* Dick Whiting <dwhiting@europa.com> */
- /* 14 July 1997 */
- /* */
- /******************************************************************************/
- /*
- $VER: 1.0 Copyright ©1997 by Dick Whiting
- $AUTHOR: Dick Whiting
- $DESCRIPTION: Strip attachments and MIME warning message from mail
- */
-
- options results
-
- stripleader=1 /* change this to 0 to NOT strip MIME warning message */
-
- argpassed=''
- parse arg argpassed
-
- Call Localize
-
- /******************************************************************************/
- /* Find out the necessary information about the file */
- /******************************************************************************/
- Init:
-
- if ~show('L','rexxsupport.library') then do
- addlib('rexxsupport.library',0,-30)
- end
-
- Address YAM 'getmailinfo file'
- mfile=result
- slpos=lastpos('/',mfile)
- copos=lastpos(':',mfile)
- filename=strip(substr(mfile,max(slpos,copos)+1))
- tmpfile = 'T:'||filename /* temporary file */
- fstate=statef(mfile) /* file information */
- fbytes=subword(fstate,2,1) /* length of file */
- fdate=subword(fstate,5,1) /* internal date */
- fmins=subword(fstate,6,1) /* minutes since midnite*/
- fticks=subword(fstate,7,1) /* ticks past minutes */
- fcomm=subword(fstate,8) /* old comment */
-
- fdate=date('E',fdate,'I') /* get date in ddmmyy */
- fdate=translate(fdate,'-','/') /* convert / to - */
- hh=fmins%60 /* get hours */
- hh=right(hh,2,'0') /* force to 2 digits */
- mm=fmins//60 /* get minutes */
- mm=right(mm,2,'0') /* force to 2 digits */
- ss=fticks%50 /* seconds */
- ss=right(ss,2,'0') /* force it */
- ftime=hh||':'||mm||':'||ss /* timestamp rebuilt */
-
- TRUE=1
- FALSE=0
- multipart=FALSE
- uu=FALSE
- header=TRUE
- boundnum=0
- lf='0A'x
- hl='#'
- striptst='#'||stripmsg
- writeatt=FALSE
- attname=''
- outopen=FALSE
- tab='09'x
- date=' -- '||date()
-
- /******************************************************************************/
- /* Do the actual stripping of the mail file. */
- /******************************************************************************/
- StripFile:
-
- if open('OUT',tmpfile,'W') then do
- outopen=TRUE
- if open('IN',mfile,'R') then do
- do until eof('IN')
- linein = readln('IN')
- writeit=TRUE
- select
- when header & linein='' then header=FALSE
- when header & upper(word(linein,1))='CONTENT-TYPE:' then do
- boundpos=pos('BOUNDARY=',upper(linein))
- if boundpos>0 then do
- boundary=substr(linein,boundpos+9)
- boundary=strip(boundary,'B','"')
- if boundary~='' then do
- boundary='--'||boundary
- endbound=boundary||'--'
- multipart=TRUE
- end
- end
- end
- when header then do
- tline=translate(linein,' ',tab)
- if right(word(tline,1),1)~=':' & substr(tline,1,1)~=' ' then do
- say linein
- header=FALSE
- foo=writeln('OUT','')
- end
- end
- when multipart then do
- select
- when linein=boundary then do
- boundnum=boundnum+1
- if boundnum=1 & stripleader then do
- stripline=hl||leadermsg||hl||lf
- foo=writeln('OUT',stripline)
- end
- if boundnum>2 then do
- stripline=lf||hl||stripmsg||attname||hl||lf
- foo=writeln('OUT',stripline)
- writeatt=FALSE
- attname=''
- end
- end
- when linein=endbound then do
- stripline=lf||hl||stripmsg||attname||hl||lf
- foo=writeln('OUT',stripline)
- multipart=FALSE
- writeatt=FALSE
- attname=''
- end
- when boundnum=0 then do
- if stripleader then writeit=FALSE
- end
- when boundnum>1 then do
- if upper(word(linein,1))='CONTENT-TYPE:' then do
- if pos('NAME=',upper(linein))>0 then do
- tline=upper(linein)
- parse var tline junk 'NAME=' attname
- attname=strip(attname,'B','"')
- attname=attname||date
- writeatt=TRUE
- end
- end
- else do
- if pos(striptst,linein) then do
- attname=subword(linein,3)
- attname=strip(attname,'T','#')
- writeatt=TRUE
- end
- end
- writeit=FALSE
- end
- otherwise nop
- end
- end
- when ~multipart then do
- select
- when upper(word(linein,1))='BEGIN' & word(linein,2)='644' then do
- attname=strip(subword(linein,3),'B')
- stripline=lf||hl||stripmsg||attname||hl||lf
- foo=writeln('OUT',stripline)
- attname=''
- uu=TRUE
- writeit=FALSE
- end
- when uu & strip(linein)='end' then do
- uu=FALSE
- writeit=FALSE
- end
- when uu then do
- select
- when strip(linein,'B')='' then writeit=FALSE
- when verify('aeiou',linein,'MATCH')=0 then writeit=FALSE
- otherwise uu=FALSE
- end
- end
- otherwise nop
- end
- end
- otherwise nop
- end
- if writeit then do
- foo=writeln('OUT',linein)
- end
- end
- if writeatt then do
- stripline=lf||hl||stripmsg||attname||hl||lf
- foo=writeln('OUT',stripline)
- if multipart then do
- foo=writeln('OUT',endbound)
- end
- end
- foo=close('IN')
- foo=close('OUT')
- outopen=FALSE
- Address Command 'C:Copy 'tmpfile' 'mfile
- Address Command 'SetDate ' mfile fdate ftime
- Address Command 'Filenote ' mfile '"'fcomm'"'
- end
- if outopen then do
- foo=close('OUT')
- end
- Address Command 'Delete 'tmpfile 'QUIET'
- end
-
- if argpassed='' then do
- Address YAM 'request "'donemsg'" "'yesnomsg'"'
- ans=result
- if ans=1 then do
- Address YAM 'mailupdate'
- end
- end
-
- exit
-
- /******************************************************************************/
- /* Variables available for localization. */
- /******************************************************************************/
- Localize:
-
- donemsg='Done..Update Index?'
- yesnomsg='Yes|No'
- stripmsg='Stripped Attachment: ' /* message for stripping MIME warning */
- leadermsg='Stripped Mime Warning' /* message for stripping attachments */
-
-
-